/* eslint-disable jsx-a11y/anchor-is-valid */
/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-11-16 15:56:01
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2022-11-21 12:37:17
 */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { listRolePost, delRolePost } from '@/api/system/rolePost';
import ResizeTable from '@/components/ResizeTable';
import { useStore } from '@/store';
import { SysRolePostDomain } from '@/type.d/system/rolePost';
import { ProColumns } from '@ant-design/pro-components';
import { Popconfirm, Table } from 'antd';
import React, { useEffect, useState } from 'react'

export type RolePostProps = {
    dataSources?: SysRolePostDomain[],
    onDelete?: (data: SysRolePostDomain)=> void,
    postOptions: any[]
}


const RolePost: React.FC<RolePostProps> = (props) => {

    const { layoutStore } = useStore();


    /**
     * 列表字段配置
     */
    const columns: ProColumns<SysRolePostDomain>[] = [
        {
            title: '角色ID',
            dataIndex: 'roleId',
            valueType: 'digit',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '职责',
            dataIndex: 'postId',
            valueType: 'select',
            align: 'left',
            width: '50',
            fieldProps: {
                options: props.postOptions
            }
        },
        {
            title: '职责名称',
            dataIndex: 'postname',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '职责编码',
            dataIndex: 'postcode',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '主键',
            dataIndex: 'rolePostId',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '授权人',
            dataIndex: 'createBy',
            valueType: 'text',
            align: 'left',
            width: '50',
        },
        {
            title: '授权时间',
            dataIndex: 'createTime',
            valueType: 'dateTime',
            align: 'left',
            width: '50',
        },
        {
            title: '修改人',
            dataIndex: 'updateBy',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '备注',
            dataIndex: 'remark',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true
        },
        {
            title: '操作',
            width: 180,
            key: 'option',
            valueType: 'option',
            render: (_dom: React.ReactNode, entity: SysRolePostDomain) => [
                <Popconfirm title="确定要删除数据吗？" okText="是" cancelText="否" onConfirm={() => {
                    props.onDelete?.(entity)
                }}>
                    <a key="delete">删除</a>
                </Popconfirm>

            ],
        },
    ];


    return (
        <ResizeTable<SysRolePostDomain>
            dataSource={props.dataSources}
            columns={columns}
            cardBordered
            pagination={false}
            revalidateOnFocus={false}
            options={false}
            rowSelection={{
            }}
        >
        </ResizeTable>
    )
}
export default RolePost;